var whois = {
	root: 'http://whois.pconline.com.cn',
    version:2.0,
    alertIp:function(ip){
        var s=document.getElementsByTagName('head')[0].appendChild(document.createElement("script"));
        s.src=this.root+"/jsAlert.jsp?ip="+ip;
    },
    lableIp:function(id,ip){
        var s=document.getElementsByTagName('head')[0].appendChild(document.createElement("script"));
        s.src=this.root+"/jsLabel.jsp?callback=jsShow&ip="+ip+"&id="+id;
    }
}

function loading(){
	$("#current_ip").html('['+IPData[0]+']');
	whois.lableIp("current_source",IPData[0]);
	$("#result_box").hide();
}

function searchInfoByIp(){
	var keyword=$("#input_box").val();
	if(!check(keyword)){
		return;
	
}

function jsShow(local){
	console.log(local);
}

function check(ip){
var pattern=/^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/;
flag_ip=pattern.test(ip);
	if(!flag_ip){
			alert("IP地址输入非法!");
			return false;
	}else{
		$("#result_box").show();
		whois.lableIp("searchresult",keyword);
	}
}}